/************提交数据**********/
mui(".mui-content").on('tap','.submitCom',function(){
    var nid=GetQueryString('nid')
    var jid=GetQueryString('jid')
    var comment=$('#comment').val()
    if(!comment){
        outLine('内容不能为空')
        return false
    }
    var issid={
        url:'user/ssoLogin',
        fromwho:'ch'
    }
    var waitingDialog
    getAjax(issid,
        function(data){
            if(data.result!=1){
                var btnArray = ['匿名评论', '去登陆'];
                mui.confirm('你尚未登录或登录已过期!', '评论', btnArray, function(e) {
                    if(e.index == 1) {
                         var backtourl=window.location.href
                         window.location.href="login.html?backurl="+backtourl
                    }else{
                        var upcommentdata={
                            url:"comment/saveComment",
                            fromwho:'news',
                            sendData:{
                                newsid:nid,
                                content:comment,
                                flag:true,
                            }
                        }
                        mui.plusReady(function(){
                            waitingDialog = plus.nativeUI.showWaiting("提交中");
                        })
                        upAjax(upcommentdata,
                            function(data){
                                mui.plusReady(function(){
                                    waitingDialog.close();
                                })
                                if(data.result==1){
                                    mui.toast('评论成功');
                                    setTimeout(function(){
                                        document.location.href = localStorage.getItem('newsbackurl')
                                    },500)
                                }
                            },
                            function(data){
                                
                            }
                        )
                    }
                })
            }else{
                var upcommentdata={
                    url:"comment/saveComment",
                    fromwho:'news',
                    sendData:{
                        newsid:nid,
                        content:comment,
                        flag:false,
                    }
                }
                mui.plusReady(function(){
                    waitingDialog = plus.nativeUI.showWaiting("提交中");
                })
                upAjax(upcommentdata,
                    function(data){
                        mui.plusReady(function(){
                            waitingDialog.close();
                        })
                        if(data.result==1){
                            mui.toast('评论成功');
                            setTimeout(function(){
                                document.location.href = localStorage.getItem('newsbackurl')
                            },500)
                        }
                    },
                    function(data){
                        
                    }
                )
            }
        },
        function(data){
            
        }
    )
});
/************提交数据end**********/